﻿
<!--@{
    Layout = null;
}

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">-->
    @*<link rel="stylesheet" href="../../lib/layui-v2.6.3/css/layui.css" media="all">*@
    <!--<link href="~/layuimini/lib/layui-v2.6.3/css/layui.css" rel="stylesheet" />-->
    @*<link rel="stylesheet" href="../../css/public.css" media="all">*@
    <!--<link href="~/layuimini/css/public.css" rel="stylesheet" />
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>
    <div class="layui-form layuimini-form">
        <div class="layui-form-item">
            <label class="layui-form-label required">当前密码</label>
            <div class="layui-input-block">
                <input type="password" name="OldPassword" lay-verify="required" lay-reqtext="当前密码不能为空" placeholder="请输入当前密码" value="" class="layui-input">-->
                @*<tip>填写自己管理账号的名称。</tip>*@
            <!--</div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label required">新密码</label>
            <div class="layui-input-block">
                <input type="password" name="NewPassword" lay-verify="required" lay-reqtext="新密码不能为空" placeholder="请输入新密码" value="" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label required">确认密码</label>
            <div class="layui-input-block">
                <input type="password" name="NewPassword2" lay-verify="required" lay-reqtext="确认密码不能为空" placeholder="请输入确认密码" value="" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
            </div>
        </div>
    </div>-->
    @*<script src="../../lib/layui-v2.6.3/layui.js" charset="utf-8"></script>*@
    <!--<script src="~/layuimini/lib/layui-v2.6.3/layui.js"></script>

    <script>
        //页面加载完才执行里面的js代码
        layui.use(['form'], function () {
            var form = layui.form,
                layer = layui.layer,
                $ = layui.$;




            //监听提交
            form.on('submit(saveBtn)', function (data) {
                debugger;

                //判断新密码两次是否正确
                if (data.field.NewPassword2 != data.field.NewPassword) {
                    layer.msg('新密码与确认密码必须相同');
                } else if (data.field.NewPassword == data.field.OldPassword){ //新密码不能和旧密码相同
                    layer.msg('新密码要与旧密码不同');
                } else {
                    //异步请求修改密码
                    $.ajax({
                        url: '/Login/EditPassword',
                        //data: data.field,
                        data: {
                            oldPassword: data.field.OldPassword,
                            newPassword: data.field.NewPassword
                        },
                        type: 'post',
                        success: function (res) {
                            if (res.isSuccess) {
                                var index = layer.alert("修改成功", {
                                    title: '提示'
                                }, function () {

                                    // 关闭弹出层
                                    layer.close(index);
                                    var iframeIndex = parent.layer.getFrameIndex(window.name);
                                    parent.layer.close(iframeIndex);

                                    //去登录页
                                    window.location = "/Login/LoginView";
                                });
                            } else {
                                layer.msg(res.msg);
                            }
                        }
                    });
                }

                return false;
            });

        });

    </script>
</body>
</html>-->
